package p.ithorns.sample.tracer;

import io.opentracing.Span;
import io.opentracing.Tracer;
import io.opentracing.util.GlobalTracer;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.MDC;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import p.ithorns.sample.tracer.jaeger.T1Service;

/**
 * Main
 *
 * @author HtL
 * @date 2025/3/20 9:28
 * @since 1.0.0
 */
@Slf4j
@RestController
@SpringBootApplication
public class Main {

    public static void main(String[] args) {
        SpringApplication.run(Main.class, args);
    }

    @Autowired
    private T1Service t1;

    // static final Tracer tracer = OpenTelemetry .noop().getTracer("test-app");

    @GetMapping("/t")
    public String test(String param) {
        // Span span = tracer.spanBuilder("test-method").startSpan();
        log.info("Hello, Log tracer: {}", param);
        t1.test();
        String res = GlobalTracer.get().activeSpan().toString();
        return res;
        // span.end();
    }


}